import time


from selenium.webdriver.common.by import By

from base.app_base_page import AppBasePage


class pageLogin(AppBasePage):
    def __init__(self,driver):
        super().__init__(driver)
        self.a=By.ID,'com.tpshop.malls:id/mine_tv'
        self.b=By.ID,'com.tpshop.malls:id/head_img'
        self.c=By.ID,'com.tpshop.malls:id/mobile_et'
        self.d=By.ID,'com.tpshop.malls:id/pwd_et'
        self.e=By.ID,'com.tpshop.malls:id/agree_btn'
        self.f=By.ID,'com.tpshop.malls:id/login_tv'
        self.toast_result=By.XPATH,'//android.widget.Toast'

    def pagelogin(self,username,password):
        time.sleep(5)
        self.app_base_click(self.a)
        self.app_base_click(self.b)
        self.app_base_input(self.c,username)
        self.app_base_input(self.d,password)
        self.app_base_click(self.e)
        self.app_base_click(self.f)
        time.sleep(2)
    # def gte_success_result(self):
    #     time.sleep(1)
    #     ser = self.app_fd_element(self.sue).text
    #     return ser
    #
    # def gte_fail_result(self):
    #     time.sleep(1)
    #     ser = self.app_fd_element(self.fail).text
    def gte_toast_result(self):
        return self.app_fd_element(self.toast_result).text
if __name__ == '__main__':
    from tools import DriverUtils
    driver=DriverUtils.get_app_driver()
    page=pageLogin(driver)
    page.pagelogin('13811115698','w123456')



